<!DOCTYPE html>
<html>
<head>
<title>Big store</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta property="og:title" content="Vide" />
<meta name="keywords" content="Big store" />
<script type="application/x-javascript">
	addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
	function hideURLbar(){ window.scrollTo(0,1); }
</script>
<link href="css/bootstrap.css" rel='stylesheet' type='text/css' />
<link href="css/style.css" rel='stylesheet' type='text/css' />
<link href="css/font-awesome.css" rel="stylesheet">

<script src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript">
	jQuery(document).ready(function($) {
		$(".scroll").click(function(event){		
			event.preventDefault();
			$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
		});
	});
</script>


	<!--<script src="js/header_category.js"/>-->
</head>
<body>
<div class="header">
	<div class="container">
		<div class="logo">
			<h1 ><a href="index.html"><b>T<br>H<br>E</b>Big Store<span>The Best Supermarket</span></a></h1>
		</div>
		<div class="head-t">
			<ul class="card">
				<li id="usercenter" style="display: none"><a class="withtoken" id="a_usercenter" href="usercenter.html" ><i class="fa fa-user" aria-hidden="true"></i>个人中心</a></li>
				<li id="login"><a class="withtoken" href="login.html" ><i class="fa fa-user" aria-hidden="true"></i>登录</a></li>
				<li id="register"><a class="withtoken" href="register.html" ><i class="fa fa-arrow-right" aria-hidden="true"></i>注册</a></li>
				<li><a class="withtoken" href="orderlist.html" ><i class="fa fa-file-text-o" aria-hidden="true"></i>订单列表</a></li>
				<li><a class="withtoken" href="wishlist.html" ><i class="fa fa-heart" aria-hidden="true"></i>收藏</a></li>
				<li><a class="withtoken" href="cart.html" ><i class="fa fa-shopping-cart" aria-hidden="true"></i>购物车</a></li>
			</ul>
		</div>
		<script type="text/javascript">
            $(function(){
                var _this1=null;
                $('.nav>li').hover(function(){
                    _this1=$(this);
                    _this1.find('.second-nav').show();
                    var _this2=null;
                    _this1.find('.second-nav').find('li').hover(function(){
                        _this2=$(this);
                        _this2.find('.third-nav').show();
                        _this2.find('.third-nav').hover(function(){
                            $(this).show();
                        },function(){
                            $(this).hide();
                        });
                    },function(){
                        _this2.find('.third-nav').hide();
                    });
                },function(){
                    _this1.find('.second-nav').hide();
                });
            });
		</script>
		<div class="nav-top">
			<nav class="navbar navbar-default">

				<div class="collapse navbar-collapse" id="bs-megadropdown-tabs">
					<ul class="nav navbar-nav ">
						<li> <!--class=" active"--> <a href="index.html" class="hyper "><span>主页</span></a></li>

						<li class="dropdown">
							<a href="#" class="dropdown-toggle  hyper" data-toggle="dropdown" >
								<span> 商品类别 <b class="caret"></b></span>
							</a>
							<ul class="dropdown-menu multi second-nav" id="dropdown-ul">
								<!--<li ><a href="#">饮料&nbsp;&nbsp;&nbsp;&nbsp;></a>
									<ul class="dropdown-menu multi third-nav">
										<li><a href="#">汽水饮料</a></li>
										<li><a href="#">酒精饮料</a></li>
										<li><a href="#">纯牛奶</a></li>
										<li><a href="#">酸牛奶</a></li>
										<li><a href="#">其他饮料</a></li>
									</ul>
								</li>
								<li><a href="#">零食&nbsp;&nbsp;&nbsp;&nbsp;></a>
									<ul class="dropdown-menu multi third-nav">
										<li><a href="#">辣条</a></li>
										<li><a href="#">饼干</a></li>
										<li><a href="#">面包</a></li>
										<li><a href="#">坚果</a></li>
										<li><a href="#">其他零食</a></li>
									</ul>
								</li>
								<li><a href="#">水果&nbsp;&nbsp;&nbsp;&nbsp;></a>
									<ul class="dropdown-menu multi third-nav">
										<li><a href="#">苹果</a></li>
										<li><a href="#">香蕉</a></li>
										<li><a href="#">葡萄</a></li>
										<li><a href="#">芒果</a></li>
										<li><a href="#">其他水果</a></li>
									</ul>
								</li>
								<li><a href="#">烟酒&nbsp;&nbsp;&nbsp;&nbsp;></a></li>
								<li><a href="#">厨具&nbsp;&nbsp;&nbsp;&nbsp;></a></li>
								<li><a href="#">蔬菜&nbsp;&nbsp;&nbsp;&nbsp;></a></li>
								<li><a href="#">鲜肉&nbsp;&nbsp;&nbsp;&nbsp;></a></li>-->
							</ul>
						</li>

						<li><a href="hot.html" class="hyper "><span> 热卖商品 </span></a></li>

						<li><a href="activities.html" class="hyper "><span> 促销活动 </span></a></li>

						<li><a href="contact.html" class="hyper"><span> 联系我们 </span></a></li>
					</ul>
				</div>
			</nav>

			<!--<div class="cart" >
                <span class="fa fa-shopping-cart my-cart-icon"><span class="badge badge-notify my-cart-badge"></span></span>
            </div>-->
			<div class="clearfix"></div>
		</div>

	</div>
</div>
  <!---->
<div data-vide-bg="video/video">
    <div class="container">
		<!--<div>-->
			<div class="search-form" style="padding: 30px">
				<div>
					<select id="ptype" style="display: block;color:white;border: 1px solid white; background: transparent;">
						<!--<option style="background: gray;" value="">全部</option>
						<option style="background: grey;" value="yinliao">饮料</option>
						<option style="background: grey;" value="lingshi">零食</option>
						<option style="background: grey;" value="shuiguo">水果</option>
						<option style="background: grey;" value="yanjiu">烟酒</option>
						<option style="background: grey;" value="chuju">厨具</option>
						<option style="background: grey;" value="shucai">蔬菜</option>-->
					</select>
					<input type="text" id="keyword" placeholder="Search..." name="Search..." />
					<input type="submit" onclick="doSearch()" value=" " />
				</div>

			</div>		
		<!--</div>	-->
    </div>
</div>

    <script>window.jQuery || document.write('<script src="js/jquery-1.11.1.min.js"><\/script>')</script>
    <script src="js/jquery.vide.min.js"></script>

<!--content-->
	<div class="product">
		<div class="container">
			<div class="spec ">
				<h3>商品搜索</h3>
				<div class="ser-t">
					<b></b>
					<span><i></i></span>
					<b class="line"></b>
				</div>
			</div>
			<div class=" con-w3l" id="productList">
							<div class="col-md-3 pro-1">
								<div class="col-m">
									<a href="other/single.html" data-toggle="modal" data-target="#myModal17" class="offer-img">
											<img src="images/of16.png" class="img-responsive" alt="">
									</a>
									<div class="mid-1">
										<div class="women">
											<h6><a href="other/single.html">Moisturiser</a>(500 g)</h6>
										</div>
										<div class="mid-2">
											<p ><label>$7.00</label><em class="item_price">$6.00</em></p>
											<div class="block">
												<div class="starbox small ghosting"> </div>
											</div>
											<div class="clearfix"></div>
										</div>
									</div>
								</div>
							</div>
							<div class="col-md-3 pro-1">
								<div class="col-m">
									<a href="#" data-toggle="modal" data-target="#myModal18" class="offer-img">
										<img src="images/of17.png" class="img-responsive" alt="">
									</a>
									<div class="mid-1">
										<div class="women">
											<h6><a href="other/single.html">  Lady Finger</a>(250 g)</h6>
										</div>
										<div class="mid-2">
											<p ><label>$5.00</label><em class="item_price">$4.50</em></p>
											  <div class="block">
												<div class="starbox small ghosting"> </div>
											</div>
											<div class="clearfix"></div>
										</div>
									</div>
								</div>
							</div>
							<div class="col-md-3 pro-1">
								<div class="col-m">
									<a href="#" data-toggle="modal" data-target="#myModal19" class="offer-img">
										<img src="images/of18.png" class="img-responsive" alt="">
									</a>
									<div class="mid-1">
										<div class="women">
											<h6><a href="other/single.html"> Ribbon</a>(1 pc)</h6>
										</div>
										<div class="mid-2">
											<p ><label>$4.00</label><em class="item_price">$3.50</em></p>
											  <div class="block">
												<div class="starbox small ghosting"> </div>
											</div>
											<div class="clearfix"></div>
										</div>

									</div>
								</div>
							</div>
							<div class="col-md-3 pro-1">
								<div class="col-m">
									<a href="#" data-toggle="modal" data-target="#myModal20" class="offer-img">
										<img src="images/of19.png" class="img-responsive" alt="">
									</a>
									<div class="mid-1">
										<div class="women">
											<h6><a href="other/single.html">Grapes</a>(500 g)</h6>
										</div>
										<div class="mid-2">
											<p ><label>$1.00</label><em class="item_price">$0.80</em></p>
											  <div class="block">
												<div class="starbox small ghosting"> </div>
											</div>
											<div class="clearfix"></div>
										</div>

									</div>
								</div>
							</div>

							<!--<div class="clearfix"></div>-->
			</div>

		</div>
	</div>
	<!--<div style="width: 100%;text-align: center">
		<nav>
			<ul class="pagination">
				<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">«</span></a></li>
				<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
				<li><a href="#">2</a></li>
				<li><a href="#">3</a></li>
				<li><a href="#">4</a></li>
				<li><a href="#">5</a></li>
				<li><a href="#" aria-label="Next"><span aria-hidden="true">»</span></a></li>
			</ul>
		</nav>
	</div>-->
<!--footer-->
<div class="footer">
	<div class="container">
		<div class="col-md-3 footer-grid">
			<h3>About Us</h3>
			<p>Big Store 是阿里巴巴集团全力打造的网上超市。Big Store 为广大网购消费者提供进口食品、食品饮料、粮油副食、美容洗护、家居用品、家庭清洁、
				母婴用品等所有生活必需品，商品品质100%保证。随时随地，轻松用手机或鼠标逛超市，生活快消品一次性购齐，不用排队、送货上门，
				还提供7天无理由退货服务。Big Store，让生活更简单。</p>
		</div>

		<div class="col-md-2 footer-grid "></div>

		<div class="col-md-3 footer-grid ">
			<h3>Menu</h3>
			<ul>
				<li><a href="index.html">主页</a></li>
				<li><a href="hot.html">热卖商品</a></li>
				<li><a href="activities.html">促销活动</a></li>
				<li><a href="contact.html">联系我们</a></li>
			</ul>
		</div>

		<div class="col-md-3 footer-grid">
			<h3>My Account</h3>
			<ul>
				<li><a href="login.html">登录</a></li>
				<li><a href="register.html">注册</a></li>
				<li><a href="wishlist.html">收藏</a></li>
				<li><a href="cart.html">购物车</a></li>
			</ul>
		</div>
		<div class="clearfix"></div>

		<div class="copy-right">
			<p> &copy; 2018 Big store. All Rights Reserved </p>
		</div>
	</div>
</div>
<!-- //footer-->


	<script type="text/javascript">

		//从浏览器URL获取GET请求参数
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
        var token = getQueryString('t')==null? '':getQueryString('t');
        //移除某个元素内的所有子节点
        function removeAllChild(nodeId){
            var div = document.getElementById(nodeId);
            //当div下还存在子节点时 循环继续
            while(div.hasChildNodes()) {
                div.removeChild(div.firstChild);
            }
        }
		//调取API获取数据
        function getData(ptype,keyword) {
            var resp = new $.ajax({
                type:"POST",
                url:"/v1/search",
                async:false,
                data:{ptype:ptype,keyword:keyword},
				success:loadCategory()
            });
            var jsonlist = resp.responseJSON;
            console.log(resp,'responseBody!!!');
            console.log(jsonlist,'bindingdata-jsondata');

            if(jsonlist != null && jsonlist != undefined){
                removeAllChild('productList');

                var productList = document.getElementById('productList');
                for(var i = 0; i < jsonlist.length; i ++){
					/*
					 <div class="col-md-3 pro-1">
					 <div class="col-m">
					 <a href="other/single.html" data-toggle="modal" data-target="#myModal17" class="offer-img">
					 <img src="images/of16.png" class="img-responsive" alt="">
					 </a>
					 <div class="mid-1">
					 <div class="women">         ------------div3
					 <h6><a href="other/single.html">Moisturiser</a>(500 g)</h6>
					 </div>
					 <div class="mid-2">
					 <p ><label>$7.00</label><em class="item_price">$6.00</em></p>
					 <div class="block">
					 <div class="starbox small ghosting"> </div>
					 </div>
					 <div class="clearfix"></div>
					 </div>
					 </div>
					 </div>
					 </div>
					 */
                    var div0 = document.createElement('div');
                    div0.setAttribute('class','col-md-3 pro-1');
                    var div1 = document.createElement('div');
                    div1.setAttribute('class','col-m');
                    var div1_a0 = document.createElement('a');
                    div1_a0.setAttribute('href','product.html?id='+jsonlist[i].id);
                    div1_a0.setAttribute('class','offer-img');
                    div1_a0.setAttribute('data-toggle','modal');
                    div1_a0.setAttribute('data-target','#myModal17');
                    var div1_a0_img = document.createElement('img');
                    div1_a0_img.setAttribute('src',''+jsonlist[i].cover);
                    div1_a0_img.setAttribute('class','img-responsive');
                    div1_a0.appendChild(div1_a0_img);

                    var div2 = document.createElement('div');
                    div2.setAttribute('class','mid-1');
                    var div3 = document.createElement('div');
                    div3.setAttribute('class','women');
                    var h6 = document.createElement('h6')
                    var aa = document.createElement('a')
                    aa.setAttribute('href','product.html?id='+jsonlist[i].id);
                    aa.innerHTML = jsonlist[i].title;
                    h6.appendChild(aa);
                    div3.appendChild(h6);

                    var div4 = document.createElement('div');
                    div4.setAttribute('class','mid-2');
                    var pEl = document.createElement('p');
                    var emEl = document.createElement('em');
                    emEl.setAttribute('class','item_price');
                    emEl.innerHTML = '￥'+jsonlist[i].price;
                    pEl.appendChild(emEl);
                    var div5 = document.createElement('div');
                    div5.setAttribute('class','block');
                    var div6 = document.createElement('div');
                    div6.setAttribute('class','starbox small ghosting');
                    div5.appendChild(div6);
                    var div7 = document.createElement('div')
                    div7.setAttribute('class','clearfix');
                    div4.appendChild(pEl);
                    div4.appendChild(div5);
                    div4.appendChild(div7);
                    div2.appendChild(div3);
                    div2.appendChild(div4);
                    div1.appendChild(div1_a0);
                    div1.appendChild(div2);
                    div0.appendChild(div1);
                    productList.appendChild(div0);
                }
			}

            var alist = document.getElementById('productList').getElementsByTagName('a');
            console.log('alist', alist);
            for (i = 0; i < alist.length; i++) {
                var hrefstr = alist[i].getAttribute('href');
                if(hrefstr == null){
                    continue;
                }
                console.log('hrefstr', hrefstr);
                if(hrefstr.indexOf('?')>0){
                    hrefstr = hrefstr +'&t='+token;
                }else{
                    hrefstr = hrefstr +'?t='+token;
                }
                alist[i].setAttribute('href', ''+hrefstr);
            }
        }
        //加载查询框类别
		function loadCategory() {
            var responseBody = new $.ajax({
                type:"GET",
                url:"/v1/categoryleaf",
                async:false,
				success:loadHeaderCategory()
            });
            console.log(responseBody,'search leaf !!!');
            var data = responseBody.responseJSON;

            removeAllChild('ptype');
            var selectEl = document.getElementById('ptype');
            var op = document.createElement('option');
            op.style.background = 'gray';
            op.setAttribute('value','');
            op.innerHTML = '--全部--';
            selectEl.appendChild(op);
            for(var i = 0; i < data.length; i ++){
                var opt = document.createElement('option');
                opt.style.background = 'gray';
                opt.setAttribute('value',''+data[i].id);
                opt.innerHTML = data[i].name;
                selectEl.appendChild(opt);
            }
        }
        //加载header的类别下拉列表
        function loadHeaderCategory() {
            var responseBody = $.ajax({
                url:"/v1/categories",
                method:"GET",
                async:false,
				/*data:{"type":type}*/
                success:loadUserName(token)
            });
            var bizData = responseBody.responseJSON;
            console.log(bizData,'!!!!!');
            var pid0 = [],pid1 = [];
            for(var i = 0; i < bizData.length; i ++ ){
                if(bizData[i].pid == 0){
                    pid0.push(bizData[i]);
                }else{
                    pid1.push(bizData[i]);
                }
            }
            console.log(pid0,'pid0!');
            console.log(pid1,'pid1!');

            removeAllChild('dropdown-ul');
            var dropdown_ul = document.getElementById('dropdown-ul');
            for(var j = 0; j < pid0.length; j ++){
                var a_el = document.createElement('a');
                a_el.innerHTML = '' + pid0[j].name + '    >';
                var ul_el = document.createElement('ul');
                ul_el.setAttribute('class','dropdown-menu multi third-nav');

                for(var k = 0; k < pid1.length; k ++){
                    if(pid1[k].pid == pid0[j].id){
						/* <li> <a> NAME </a> </li>*/
                        var in_a_el = document.createElement('a');
                        in_a_el.setAttribute('href','search.html?ptype='+pid1[k].id);
                        in_a_el.innerHTML = '' + pid1[k].name;

                        var in_li_el = document.createElement('li');
                        in_li_el.appendChild(in_a_el);

                        ul_el.appendChild(in_li_el)
                    }
                }
                var li_el = document.createElement('li');
                li_el.appendChild(a_el);
                li_el.appendChild(ul_el);

                dropdown_ul.appendChild(li_el);
            }
        }
        function loadUserName(the_token) {
            var responseBody = $.ajax({
                url:"/v1/usersession",
                method:"GET",
                async:false,
                headers:{t:the_token}
            });
            var uidstr = responseBody.responseText;
            //console.log('uidstr',responseBody);
            if(uidstr != '-1' && uidstr != 'undefined'){
                var auc = document.getElementById('a_usercenter');
                auc.setAttribute('href',auc.getAttribute('href')+'&u='+uidstr);
                document.getElementById('usercenter').style.display='inline-block';
                document.getElementById('login').style.display='none';
                document.getElementById('register').style.display='none';
            }
        }
        //主动查询
		function doSearch() {
            var ptype = $('#ptype').val();
            var keyword = $('#keyword').val();

            console.log(ptype,'ptype-dosearch');
            console.log(keyword,'keyword-dosearch');

            getData(ptype,keyword);

        }
        //被动查询
		$(document).ready(function() {

            var ptype = getQueryString('ptype');
            var keyword = getQueryString('keyword');
            console.log(ptype,'ptype-trigger');
            console.log(keyword,'keyword-trigger');
			if((ptype == null && keyword == null) || (ptype == '' && keyword == '')){

			}else{
                getData(ptype,keyword);
			}
            //loadUserName(token);
            var alist = document.getElementsByTagName('a');
            console.log('alist', alist);
            for (i = 0; i < alist.length; i++) {
                var hrefstr = alist[i].getAttribute('href');
                if(hrefstr == null){
                    continue;
                }
                console.log('hrefstr', hrefstr);
                if(hrefstr.indexOf('?')>0){
                    hrefstr = hrefstr +'&t='+token;
                }else{
                    hrefstr = hrefstr +'?t='+token;
                }
                alist[i].setAttribute('href', ''+hrefstr);
            }

			$().UItoTop({ easingType: 'easeOutQuart' });
		});
	</script>


	<a href="#" id="toTop" style="display: block;"> <span id="toTopHover" style="opacity: 1;"> </span></a>

  </body>
</html>